/*
 * @Author: your name
 * @Date: 2020-08-23 20:00:10
 * @LastEditTime: 2020-08-26 18:58:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \react-exam\src\store\exam.ts
 */
/* 引入mobx  action:动作  observable：装饰器  （useObservable:使数据变为响应式）  */
import { observable, action } from 'mobx';

/* 引入获取所有展示接口api */
import { AddExam,getPaperlist } from '../service/index';

/* 引入类型 */
import { AddExamItme, AllExamItem } from '../utils/interface';

export default class Consumer{
    // [key: string]: any
    @observable
    pageListData = [];
    /* 考试添加 */
    @observable
    addExamAction = [];

    /* 获取试卷列表 */
    @action
    async getPaperlistAction(params?:AllExamItem){
        let result=await getPaperlist({...params});
        /* console.log('获取试卷列表。。。',result.data); */
        
        if(result.data.code===1){
            this.pageListData=result.data.exam
            
        }
        // console.log('exam',this.pageListdata)
    }


    /* 创建试卷 */
    @action
    async getConsumerListAction(params:AddExamItme){
        /* 发送请求 */
        let result = await AddExam({...params});
        /* console.log('getConsumerListAction...',result.data.data); */
        
        /* 判断 */
        if (result.data){
            this.addExamAction = result.data.data;
        }
    };
}